<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<%@page import="java.util.Date"%>
<%
	response.setHeader("Pragma","No-Cache");  
	response.setHeader("Cache-Control","No-Cache");  
	response.setDateHeader("Expires",0);  
	long dateTime = new Date().getTime();
%>

<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="imgDomain"><%=ServerValue.getImgDomain()%></c-rt:set>
<link rel="stylesheet" href="/css/jquery.tooltip.css" />
<script src="/js/jquery.tooltip.min.js" type="text/javascript"></script>
<script src="/js/jquery.MultiFile.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" charset="UTF-8" src="/js/yaodian100.common.js"></script>
<c-rt:if test="${product.graphicType eq 'S'}">
	<c-rt:set var="graphicIdType" value="main"/>
	<c-rt:set var="mainTypeSize" value="120"/>
	<c-rt:set var="mainTypeWidth" value="500"/>
	<c-rt:set var="mainTypeHeight" value="500"/>
</c-rt:if>
<c-rt:if test="${product.graphicType eq 'R'}">
	<c-rt:set var="graphicIdType" value="rmain"/>
	<c-rt:set var="mainTypeSize" value="100"/>
	<c-rt:set var="mainTypeWidth" value="400"/>
	<c-rt:set var="mainTypeHeight" value="530"/>	
</c-rt:if>
<script language="javascript">
	$().ready(function(){
		$("tr[id*='tdDesc_']").tooltip();
		 
		chkFileData();

		//修改时才要做
		if ( "${mainImgSize}" > 0 ){
			//default 载入的商品图类型
			$("#specImg").show();
			$("#prodImg").show();
			$("#specImgToggle").click(function(){
				if ( $("#specImg").css("display") != "none" ){
					$("#specImgToggle").text("(+展开)");
					$("#specImg").hide();
				}else{
					$("#specImgToggle").text("(-收缩)");
					$("#specImg").show();
				}
			});
			$("#prodImgToggle").click(function(){
				if ( $("#prodImg").css("display") != "none" ){
					$("#prodImgToggle").text("(+展开)");
					$("#prodImg").hide();
				}else{
					$("#prodImgToggle").text("(-收缩)");
					$("#prodImg").show();
				}
			});
		}

		/*清除圖檔*/
		$(":input[type='button'][name='clearBtn']").each(function(index){
			$(this).click(function(event){
				//清除icon
				if ( $(this).attr("id").indexOf("clear_icon_") != -1 ){
					var splitId = $(this).attr("id").split("_")[2];
					event.preventDefault();
					$("#correct_icon_" + splitId).val("");
					$("#image_icon_" +splitId).val("");
				}
				//清除方形主图(for新增)
				if ( $(this).attr("id").indexOf("clear_main_") != -1 ){
					var splitId = $(this).attr("id").split("_");
					var tempId = splitId[2] + "_" + splitId[3];
					event.preventDefault();
					$("#correct_main_" + tempId).val("");
					$("#image_main_" +tempId).val("");
				}
				//清除长形主图(for新增)
				if ( $(this).attr("id").indexOf("clear_rmain_") != -1 ){
					var splitId = $(this).attr("id").split("_");
					var tempId = splitId[2] + "_" + splitId[3];
					event.preventDefault();
					$("#correct_rmain_" + tempId).val("");
					$("#image_rmain_" +tempId).val("");
				}
				//清除方形、长形主图(for修改)
				if ( $(this).attr("id").indexOf("clear_upd${graphicIdType}_") != -1 ){
					var splitId = $(this).attr("id").split("_");
					var tempId = splitId[2] + "_" + splitId[3];
					event.preventDefault();
					$("#correct_upd${graphicIdType}_" + tempId).val("");
					$("#image_upd${graphicIdType}_" +tempId).val("");
				}				
				//清除批次上传图檔
				if ( $(this).attr("id").indexOf("clear_batch_") != -1 ){
					var splitId = $(this).attr("id").split("_")[2];
					event.preventDefault();
					$("#correct_batch_" + splitId).val("");
					$("#image_batch_" +splitId).val("");
				}
			});
		});
		
		/*批次修改/上传图檔*/
		$("#batchbtn").click(function(){
			$(":input[id*='image_batch_']").each(function(){
				if ( $(this).val() != "" ){
					var id = this.id.split("_")[2];
					$("#batchSpan" + id).html("<input type='hidden' name='batchDetails' value='" + $("#imgId_" + id).val() + "'/>");
				}
			});
			err = 0;
			var msg = "";
			if ( "${selImageType}" =="RMAIN" || "${selImageType}" =="MAIN" || "${selImageType}" =="IMGB"){
				$(":input[type='file'][name='batch']").each(function(index){
					var id = this.id.split("_")[2];
					if ( $("#correct_batch_" + id).val() != ""  ){
						if ( "${selImageType}" =="RMAIN" || "${selImageType}" =="MAIN" ){
							msg = msg + trim($("#td" + id ).text()) + "," + "\n";
							err++;
						}
						if ( "${selImageType}" =="IMGB" ){
							msg = msg + trim($("#IMGB_FILE_NAME_" + id ).val()) + "," + "\n";
							err++;
						}
					} 
				});
				if ( msg != "" ){
					alert(msg + "的图片规格不符合规范，请检查图片尺寸、大小。");
					return false;
				}
			}
			if(err==0) 
				$("#picList").submit();
		});

		
		$("#selImageType").change(function(){
			$("#editProposeForm").submit();
		});			

		/*清空要修改的资料*/
		$("input[name='updSpecImgData']").each(function(){
			$(this).val("");
		});

		
		/*上传主规格长/方形图、icon*/
		$("#saveSpecImg").click(function(){
			$("#tempIcon").val("");
			$("#tempMaim").val("");
			$("#tempRmain").val("");
			var err = 0;
			if ( "${mainImgSize eq 0}" == "true"){//新增
				$("input[id*='image_icon_']").each(function(){
					if ( $(this).val() != "" ){
						if ( $("#tempIcon").val() == "" ){
							$("#tempIcon").val($(this).attr("id").split("_")[2]);
						}else{
							$("#tempIcon").val($("#tempIcon").val() + "," + $(this).attr("id").split("_")[2]);
						}
					}
				});
				$("input[id*='image_main_']").each(function(){
					var tempId = $(this).attr("id").split("_");
					if ( tempId[2] == "1" ){//只有第一张为必填
						ydClean("msg_main_1_" + tempId[3]);
					}
					if ( $(this).val() != "" ){
						if ( $("#tempMain").val() == "" ){
							$("#tempMain").val(tempId[3]);
						}else{
							$("#tempMain").val($("#tempMain").val() + "," + tempId[3]);
						}
					}else{
						if ( tempId[2] == "1" ){//只有第一张为必填
							ydValidate("msg_main_1_" + tempId[3],"尚未选择上传档案，请重新选择！");
							err++;
						}
					}
				});
				$("input[id*='image_rmain_']").each(function(){
					var tempId = $(this).attr("id").split("_");
					if ( tempId[2] == "1" ){//只有第一张为必填
						ydClean("msg_rmain_1_" + tempId[3]);
					}
					if ( $(this).val() != "" ){
						if ( $("#tempRmain").val() == "" ){
							$("#tempRmain").val(tempId[3]);
						}else{
							$("#tempRmain").val($("#tempRmain").val() + "," + tempId[3]);
						}
					}else{
						if ( tempId[2] == "1" ){//只有第一张为必填
							ydValidate("msg_rmain_1_" + tempId[3],"尚未选择上传档案，请重新选择！");
							err++;
						}
					}
				});
				var chkCover = false;
				$("input[name=cover][type='radio']").each(function(){
					if ( $(this).attr("checked") == true ){
						chkCover = true;
					}
				});
				if ( !chkCover ){
					alert("请设定规格封面图");
					err++;
				}
			}else{//修改
				$("input[id*='image_icon_']").each(function(){
					if ( $(this).val() != "" ){
						if ( $("#tempIcon").val() == "" ){
							$("#tempIcon").val($(this).attr("id").split("_")[2]);
						}else{
							$("#tempIcon").val($("#tempIcon").val() + "," + $(this).attr("id").split("_")[2]);
						}
					}
				});
				//主规格方形/长形图的第一张图与后面四张图分开处理(第一张图为必填)
				$("input[id*='image_main_1']").each(function(){
					if ( $(this).val() != "" ){
							$("#tempMain").val($(this).attr("id").split("_")[3]);
					}
				});
				$("input[id*='image_rmain_1']").each(function(){
					if ( $(this).val() != "" ){
						$("#tempRmain").val($(this).attr("id").split("_")[3]);
					}
				});
				//处理后面四张图(非必填)image_${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}
				$("input[name='updMain'][type='file']").each(function(){
					var splitId = $(this).attr("id").split("_");
					$("#updSpec_" + splitId[2] + "_" + splitId[3]).val("");
					if ( typeof $("#delSpecImgIds_${graphicIdType}_" + splitId[2] + "_" + splitId[3])[0] != "undefined" ){//update
						if ( $("#delSpecImgIds_${graphicIdType}_" + splitId[2] + "_" + splitId[3])[0].checked == false ){
							if ( "" != $(this).val() ){
								$("#updSpec_" + splitId[2] + "_" + splitId[3]).val(splitId[3] + "#upd#" + $(this).val() + "#" + splitId[2]);
							}else{
								$("#updSpec_" + splitId[2] + "_" + splitId[3]).val(splitId[3] + "#none#" + splitId[2] + "#0");
							}
						}
					}else{
						if ( "" != $(this).val() ){//new
							$("#updSpec_" + splitId[2] + "_" + splitId[3]).val(splitId[3] + "#new#" + $(this).val()+ "#0");
						}
					}
				});
			}
			//送出前再检查一次檔案大小&尺寸
			var fileSizeErr = 0;
			var typesArr = ["main","rmain","icon","upd${graphicIdType}"];
			jQuery.each(typesArr,function(index,item){
				$("input[id*='correct_" + item + "']").each(function(){
					if ( $(this).val() != "" ){
						fileSizeErr++;
					}
				});
			});
			if ( fileSizeErr > 0 ){
					alert("图片规格不符合规范，请检查图片尺寸、大小。");
					return false;
			}
		if ( err == 0 )
			$("#uploadSpecImg").submit();
		});
		
		//上传描述图/其他图
		$("#saveProdImg").click(function(){
			if ( $("#MultiFile8_F1").val() == "" && $("#MultiFile8_F2").val() == ""){
				alert("尚未选择上传档案，请重新选择！");
				return false;
			}
			$("#uploadProdImg").submit();
		});

		/*设为封面*/
		$("input[id*='cover_'][type='button']").click(function(){
			$.post("${midContextPath}/image2/changeCover.do",{productId : '${productId}',mainSpecId:$(this).attr("id").split('_')[1]},coverCallback,"json");
		});

		/*上一步*/
		$("#previous").click(function(){
			location.href="${midContextPath}/product2/spec.do?productId=${productId}";
		});

		$("#next").click(function(){
			if ( "${mainImgSize eq 0}" == "true"){//新增
				var err = 0 ;
				$("input[id*='image_main_']").each(function(){
					var tempId = $(this).attr("id").split("_");
					if ( tempId[2] == "1" ){//只有第一张为必填
						ydClean("msg_main_1_" + tempId[3]);
					}
					if ( $(this).val() == "" && tempId[2] == "1" ){//只有第一张为必填
						ydValidate("msg_main_1_" + tempId[3],"尚未选择上传档案，请重新选择！");
						err++;
					}
				});
				$("input[id*='image_rmain_']").each(function(){
					var tempId = $(this).attr("id").split("_");
					if ( tempId[2] == "1" ){//只有第一张为必填
						ydClean("msg_rmain_1_" + tempId[3]);
					}
					if ( $(this).val() == "" && tempId[2] == "1" ){//只有第一张为必填
						ydValidate("msg_rmain_1_" + tempId[3],"尚未选择上传档案，请重新选择！");
						err++;
					}
				});
				if ( err > 0 ){
					return false;
				}
			}
			//送出前再检查一次檔案大小&尺寸
			var fileSizeErr = 0;
			var typesArr = ["main","rmain","icon","upd${graphicIdType}"];
			jQuery.each(typesArr,function(index,item){
				$("input[id*='correct_" + item + "']").each(function(){
					if ( $(this).val() != "" ){
						fileSizeErr++;
					}
				});
			});
			if ( fileSizeErr > 0 ){
					alert("图片规格不符合规范，请检查图片尺寸、大小。");
					return false;
			}else{
				$("#saveImgStep").submit();
			}
		});
	});

	//设为当前封面
 	function coverCallback(coverId){
 	 	if ( "" != coverId ){
 	 		$("td[id*='reset_cover_']").each(function(){
 	 	 		if ( $(this).attr("id").split("_")[2] == coverId ){
 	 	 		 $(this).html("当前商品封面");
 	 	 		}else{
 	 	 			$(this).html('<input type="button" name="cover" id="cover_' + $(this).attr("id").split("_")[2] + '" value="设为当前商品封面"/>');
 	 	 		}
 	 		});
 	 	}
 	}

	//左移
	function moveDivLeft(anchor){
		var selfId = $(anchor).parent().parent().parent().attr("id");
		var splitId = selfId.split("_");
		if (typeof $("#"+selfId).prev().attr("id") != "undefined"){
			var leftId = $("#"+selfId).prev().attr("id");
			var self = $("#"+selfId).html();
			var left = $("#"+leftId).html();
			var s1 = $("#"+selfId).children().clone();
			var l1 = $("#"+leftId).children().clone();
			$("#"+selfId).html(l1);
			$("#"+leftId).html(s1);
		}
	}

	//右移
	function moveDivRight(anchor){
		var selfId = $(anchor).parent().parent().parent().attr("id");
		var splitId = selfId.split("_");
		if (typeof $("#"+selfId).next().attr("id") != "undefined"){
			var rightId = $("#"+selfId).next().attr("id");
			var s1 = $("#"+selfId).children().clone();
			var r1 = $("#"+rightId).children().clone();
			$("#"+selfId).html(r1);
			$("#"+rightId).html(s1);
		}
	}	

	function chkFileData(){
		$(":input[type='file']").each(function(index){
			$(this).change(function(){
				if ( "" != $(this).val() ){
					/*检查icon图檔大小、长宽*/
					if ( "icon" == $(this).attr("name") ){
						var splitId = $(this).attr("id").split("_")[2];
						checkImg(this,$("#size_icon_" + index).val(),$("#width_icon_" + splitId).val(),$("#height_icon_" + splitId).val(),$("#correct_icon_" + splitId),"");
					}
					/*检查main图檔大小、长宽*/
					if ( "main" == $(this).attr("name")){
						var splitId = $(this).attr("id").split("_");
						var tempId = splitId[2] + "_" + splitId[3];
						checkImg(this,$("#size_main_" + tempId).val(),$("#width_main_" + tempId).val(),$("#height_main_" + tempId).val(),$("#correct_main_" + tempId),"");
					}
					/*检查rmain图檔大小、长宽*/
					if ( "rmain" == $(this).attr("name")){
						var splitId = $(this).attr("id").split("_");
						var tempId = splitId[2] + "_" + splitId[3];
						checkImg(this,$("#size_rmain_" + tempId).val(),$("#width_rmain_" + tempId).val(),$("#height_rmain_" + tempId).val(),$("#correct_rmain_" + tempId),"");
					}
					/*检查修改時的main or rmain图檔大小、长宽*/
					if ( "updMain" == $(this).attr("name")){
						var splitId = $(this).attr("id").split("_");
						var tempId = splitId[2] + "_" + splitId[3];
						checkImg(this,$("#size_upd${graphicIdType}_" + tempId).val(),$("#width_upd${graphicIdType}_" + tempId).val(),$("#height_upd${graphicIdType}_" + tempId).val(),$("#correct_upd${graphicIdType}_" + tempId),"");
					}
					/*检查批次上传图檔大小、长宽*/
					if ( "${selImageType}" =="RMAIN" || "${selImageType}" =="MAIN" || "${selImageType}" =="IMGB"){
						if ( "batch" == $(this).attr("name")){
							var splitId = $(this).attr("id").split("_");
							var tempId = splitId[2];
							if ( "${selImageType}" =="RMAIN" || "${selImageType}" =="MAIN" ){
								checkImg(this,$("#size_batch_" + tempId).val(),$("#width_batch_" + tempId).val(),$("#height_batch_" + tempId).val(),$("#correct_batch_" + tempId),"");
							}
							if ( "${selImageType}" =="IMGB"){
								checkPrdtImg(this,$("#width_batch_" + tempId).val(),$("#height_batch_" + tempId).val(),$("#correct_batch_" + tempId),"");
							}
							if ( "" != $("#correct_batch_" + tempId).val() ){
								clearErrorImg(this);
							}
						}
					}
				}
			});
		});						
	}
</script>
<h1>
	商品管理 - 商品图檔	<br/>
	<div class="f-link">
	<a href="${midContextPath}/product2/list.do">回商品列表页</a>
	</div>
</h1>
<s:actionerror escape="false"/>
<c-rt:if test="${not empty productId}">
	<jsp:include page="/WEB-INF/jsp/product/commonMenu2.jsp"/>
</c-rt:if>
<table class="tb-data" width="100%">
	<tr>
		<th width="20%">商品名称（商品编号）</th>
    <td>${productName}(${productId})</td>
	</tr>
	<tr>
		<th>主檔图显示类型</th>
		<td>
			<c-rt:if test="${product.graphicType eq 'S'}">方形图
				<c-rt:set var="graphicType" value="MAIN"/>
				<c-rt:set var="graphicIdType" value="main"/>
			</c-rt:if>
			<c-rt:if test="${product.graphicType eq 'R'}">长形图
				<c-rt:set var="graphicType" value="RMAIN"/>
				<c-rt:set var="graphicIdType" value="rmain"/>
			</c-rt:if>
			<a href="${midContextPath}/product2/edit.do?productId=${product.productId}">返回商品主檔修改</a>
		</td>
	</tr>
</table>
<br/><br/>
<c-rt:if test="${mainImgSize > 0}"> 
	商品系统图	<a id="specImgToggle" href="javascript:;" class="a-more a-blue">(-收缩)</a><br/><br/>
</c-rt:if>
<div id="specImg">
<c-rt:set var="majorSize" value="0"/>
<s:form action ="uploadSpecImg.do" id="uploadSpecImg" method ="post" enctype ="multipart/form-data" >
<table width="100%" class="tb-data">
	<tbody>
		<tr>
       <th class="bigth" colspan="5">商品系统图</th>
    </tr>
    <tr>
    	<th>主规格</th>
      <th>主规格示意图(40x40&lt;2k)<br><span class="txt-gy">若不上传则使用方形图等比缩小</span></th>
      <th><span class="txt-red">*</span>主规格方形图(500x500&lt;120k)</th>
      <th><span class="txt-red">*</span>主规格长形图(400x530&lt;100k)</th>
      <th>封面</th>
     </tr>
     <c-rt:forEach items="${product.specMajors}" var="major" varStatus="mIndex">
     <c-rt:if test="${major.isDelete eq 'N'}">
     <c-rt:set var="majorSize" value="${majorSize+1}"/>
     <tr class="${mIndex.count % 2 == 0 ? 'bg-yl' : ''}">
     	<td valign="top" rowspan="2">${major.mainSpecName}
     		<c-rt:if test="${mainImgSize > 0}"> 
     			<br/>
     			<a href="${midContextPath}/image2/viewImgDetail.do?productId=${product.productId}&mainSpecId=${major.mainSpecId}" target="_blank">规格图檔明细</a>
     		</c-rt:if>
     	</td>
     	<td valign="top" class="set-pdimg">
     		<div class="wrap">
     		<c-rt:choose>
	     		<c-rt:when test="${empty majorSpecImgMap[major.mainSpecId]['ICON'] }">
	     			<div class="pdimg-null40">?</div>
		     	</c-rt:when>
		     	<c-rt:otherwise>
	     				<img src="${imgDomain}${majorSpecImgMap[major.mainSpecId]['ICON'][0].imgFilePath}?nocache=<%=dateTime%>"  width="40" height="40"  onError="this.src='/PImg/40x40.gif'"/>
		     	</c-rt:otherwise>
		    </c-rt:choose>
		   	</div>
     		<div class="wrap">
     			<input class="multi MultiFile-applied" type="file" accept="gif|jpg" maxlength="1" id="image_icon_${major.mainSpecId}" name="icon" size="10%"/>
     			<input type="button" name="clearBtn" value="清除图檔" id="clear_icon_${major.mainSpecId}"/>
     			<input type="hidden" id="correct_icon_${major.mainSpecId}" value=""/>
     			<input type="hidden" id="width_icon_${major.mainSpecId}" value="40"/>
					<input type="hidden" id="height_icon_${major.mainSpecId}" value="40"/>
					<input type="hidden" id="size_icon_${major.mainSpecId}" value="2"/>     			
     			<span id="imgNos_icon_${mIndex.count}"></span>
     		</div>
     	</td>
      <td valign="top" class="set-pdimg">
      	<div class="wrap">
      	<c-rt:choose>
	      	<c-rt:when test="${empty majorSpecImgMap[major.mainSpecId]['MAIN'] }">
		      	<div class="pdimg-null75">?</div>
		      </c-rt:when>
	     		<c-rt:otherwise>
     				<img src="${imgDomain}${majorSpecImgMap[major.mainSpecId]['MAIN'][0].imgFilePath}?nocache=<%=dateTime%>" width="75" height="75"  onError="this.src='/PImg/blank_75.gif'"/>
     			</c-rt:otherwise>
     		</c-rt:choose>
     		</div>
   			<div class="wrap">
   				<input class="multi MultiFile-applied" type="file" accept="gif|jpg" maxlength="1" id="image_main_1_${major.mainSpecId}" name="main" size="10%"/>
   				<input type="button" name="clearBtn" value="清除图檔" id="clear_main_1_${major.mainSpecId}"/>
   				<input type="hidden" id="correct_main_1_${major.mainSpecId}" value=""/>
     			<input type="hidden" id="width_main_1_${major.mainSpecId}" value="500"/>
					<input type="hidden" id="height_main_1_${major.mainSpecId}" value="500"/>
					<input type="hidden" id="size_main_1_${major.mainSpecId}" value="120"/> 
					<span id="msg_main_1_${major.mainSpecId}"></span>  				
   			</div>
      </td>
      <td valign="top" class="set-pdimg">
      	<div class="wrap">
      	<c-rt:choose>
	      	<c-rt:when test="${empty majorSpecImgMap[major.mainSpecId]['RMAIN']}">      
	      		<div class="pdimg-null70">?</div>
		      </c-rt:when>
	     		<c-rt:otherwise>
     				<img src="${imgDomain}${majorSpecImgMap[major.mainSpecId]['RMAIN'][0].imgFilePath}?nocache=<%=dateTime%>" width="75" height="93"  onError="this.src='/PImg/blank_r93.gif'"/>
     			</c-rt:otherwise>
     		</c-rt:choose>
     		</div>		 
   			<div class="wrap">
   				<input class="multi MultiFile-applied" type="file" accept="gif|jpg" maxlength="1" id="image_rmain_1_${major.mainSpecId}" name="rmain" size="10%"/>
   				<input type="button" name="clearBtn" value="清除图檔" id="clear_rmain_1_${major.mainSpecId}"/>
   				<input type="hidden" id="correct_rmain_1_${major.mainSpecId}" value=""/>
     			<input type="hidden" id="width_rmain_1_${major.mainSpecId}" value="400"/>
					<input type="hidden" id="height_rmain_1_${major.mainSpecId}" value="530"/>
					<input type="hidden" id="size_rmain_1_${major.mainSpecId}" value="100"/>   
					<span id="msg_rmain_1_${major.mainSpecId}"></span>  		  				
   			</div>
      </td>
      <td valign="middle" align="center" id="reset_cover_${major.mainSpecId}">
      	<c-rt:choose>
      		<c-rt:when test="${mainImgSize eq 0}">
     				<input type="radio" name="cover" value="${major.mainSpecId}" ${majorSize eq 1 ? "checked=checked" : ""}/>设为当前封面
      		</c-rt:when>
      		<c-rt:otherwise>
     				<c-rt:if test="${not empty majorSpecImgMap[major.mainSpecId]['MAIN'] and not empty majorSpecImgMap[major.mainSpecId]['RMAIN']}">
     					<c-rt:if test="${major.isCover eq 'Y'}">当前商品封面</c-rt:if>
     					<c-rt:if test="${major.isCover eq 'N'}"><input type="button" name="cover" id="cover_${major.mainSpecId}" value="设为当前商品封面"/></c-rt:if>
     				</c-rt:if>
      		</c-rt:otherwise>
      	</c-rt:choose>
      </td>
    </tr>
    <tr class="${mIndex.count % 2 == 0 ? 'bg-yl' : ''}">
    	<td valign="top" class="set-pdimg" colspan="4">
		      <div class="upload-pdimg-wrap">
		      	<div class="pdimg-muti-wrap"><div class="pdimg-muti"><div class="pdimg-null84"></div><div class="pdimg-null16"></div><div class="pdimg-null16b"></div><div class="pdimg-null16b"></div><div class="pdimg-null16b"></div><div class="pdimg-null16b"></div></div><div class="wrap">显示位置范例</div></div>
		        	<div style="line-height:111px;" class="pdimg-muti-wrap">=</div>
		        	<table><tr>
			      	<c-rt:choose>
				      	<c-rt:when test="${empty majorSpecImgMap[major.mainSpecId][graphicType] }">
				      		<c-rt:forEach begin="2" end="5" varStatus="addSpecImg">
				      		<td id="${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}">
				         	<div class="pdimg-nulls-wrap">
				         		<div class="wrap">
				         			<c-rt:if test="${product.graphicType eq 'S'}"><div class="pdimg-null75">?</div></c-rt:if>
				         			<c-rt:if test="${product.graphicType eq 'R'}"><div class="pdimg-null70">?</div></c-rt:if>
				         		</div>
				         		<div class="wrap">
				         			<input class="multi MultiFile-applied" type="file" accept="gif|jpg" maxlength="1" id="image_${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}" name="${graphicIdType}" size="8%"/><br/>
				         			<a href="javascript:void(0);" onClick="return moveDivLeft($(this));">←左移</a>
				         			<a href="javascript:void(0);" onClick="return moveDivRight($(this));">右移→</a>
					         		<input type="button" name="clearBtn" value="清除图檔" id="clear_${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}"/>
					         		<input type="hidden" id="correct_${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}" value=""/>
						     			<input type="hidden" id="width_${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}" value="${mainTypeWidth}"/>
											<input type="hidden" id="height_${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}" value="${mainTypeHeight}"/>
											<input type="hidden" id="size_${graphicIdType}_${addSpecImg.index}_${major.mainSpecId}" value="${mainTypeSize}"/> 					         		
				         		</div>
				         	</div>
				         	</td>
				         	</c-rt:forEach>
				        </c-rt:when>
				        <c-rt:otherwise>
				        	<c-rt:set var="mapSize" value="${fn:length(majorSpecImgMap[major.mainSpecId][graphicType])-1}"/>
				        	<c-rt:forEach items="${majorSpecImgMap[major.mainSpecId][graphicType]}" var="updSpecImg" varStatus="row_index">
				        		<c-rt:if test="${row_index.count ge 2}">
				        		<td id="${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}">
										<div class="pdimg-nulls-wrap">
											<div class="wrap">
					         			<c-rt:if test="${product.graphicType eq 'S'}">
					         				<img src="${imgDomain}${updSpecImg.imgFilePath}?nocache=<%=dateTime%>" width="75" height="75" />
					         			</c-rt:if>
				         				<c-rt:if test="${product.graphicType eq 'R'}">
				         					<img src="${imgDomain}${updSpecImg.imgFilePath}?nocache=<%=dateTime%>" width="75" height="99" />
				         				</c-rt:if>
											</div>
											<div class="wrap">
						         		<input class="multi MultiFile-applied" type="file" accept="gif|jpg" maxlength="1" id="image_upd${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}" name="updMain" size="8%"/><br/>
						         		<a href="javascript:void(0);" onClick="return moveDivLeft($(this));">←左移</a>
				         				<a href="javascript:void(0);" onClick="return moveDivRight($(this));">右移→</a>
						         		<input type="button" name="clearBtn" value="清除图檔" id="clear_upd${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}"/>
						         		<input type="checkbox" name="delSpecImgIds" id="delSpecImgIds_${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}" value="${updSpecImg.id}"/>删除
						         		<input type="hidden" id="updSpec_${updSpecImg.id}_${major.mainSpecId}" name="updSpecImgData"/>
						         		<input type="hidden" id="correct_upd${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}" value=""/>
							     			<input type="hidden" id="width_upd${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}" value="${mainTypeWidth}"/>
												<input type="hidden" id="height_upd${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}" value="${mainTypeHeight}"/>
												<input type="hidden" id="size_upd${graphicIdType}_${updSpecImg.id}_${major.mainSpecId}" value="${mainTypeSize}"/> 					         		
						         	</div>
				         		</div>
				         		</td>
				         		</c-rt:if>
				         	</c-rt:forEach>
				         	<c-rt:forEach begin="2" end="${5-mapSize}" var="row_index">
				         	<td id="${graphicIdType}_${mapSize+row_index}_${major.mainSpecId}">
										<div class="pdimg-nulls-wrap">
											<div class="wrap">
												<c-rt:if test="${product.graphicType eq 'S'}"><div class="pdimg-null75">?</div></c-rt:if>
				         				<c-rt:if test="${product.graphicType eq 'R'}"><div class="pdimg-null70">?</div></c-rt:if>
											</div>
											<div class="wrap">
					         			<input class="multi MultiFile-applied" type="file" accept="gif|jpg" maxlength="1" id="image_upd${graphicIdType}_${mapSize+row_index}_${major.mainSpecId}" name="updMain" size="8%"/><br/>
					         			<a href="javascript:void(0);" onClick="return moveDivLeft($(this));">←左移</a>
				         				<a href="javascript:void(0);" onClick="return moveDivRight($(this));">右移→</a>
					         			<input type="button" name="clearBtn" value="清除图檔" id="clear_upd${graphicIdType}_${mapSize+row_index}_${major.mainSpecId}"/>
					         			<input type="hidden" id="updSpec_${mapSize+row_index}_${major.mainSpecId}" name="updSpecImgData"/>
					         			<input type="hidden" id="correct_upd${mapSize+row_index}_${major.mainSpecId}" value=""/>
							     			<input type="hidden" id="width_upd${graphicIdType}_${mapSize+row_index}_${major.mainSpecId}" value="${mainTypeWidth}"/>
												<input type="hidden" id="height_upd${graphicIdType}_${mapSize+row_index}_${major.mainSpecId}" value="${mainTypeHeight}"/>
												<input type="hidden" id="size_upd${graphicIdType}_${mapSize+row_index}_${major.mainSpecId}" value="${mainTypeSize}"/> 					         		
					         		</div>
					         	</div>
					         	</td>
				         	</c-rt:forEach>
				        </c-rt:otherwise>		  
				       </c-rt:choose> 
				       </tr></table>
         	</div>
      </td>
    </tr>
    </c-rt:if>
    </c-rt:forEach>
    <tr>
	    <td class="set-pdimg-upload" colspan="5">
	    	<input type="hidden" name="tempIcon" id="tempIcon"/>
	    	<input type="hidden" name="tempMain" id="tempMain"/>
	    	<input type="hidden" name="tempRmain" id="tempRmain"/>
	    	<input type="hidden" name="tempNewMain" id="tempNewMain"/>
	    	<input type="hidden" name="productId" value="${productId}"/>
	    	<input type="hidden" name="tempSpecShowSeq" id="tempSpecShowSeq"/>
	    	<input type="button" value="上传主规格图片/保存设置" name="saveSpecImg" id="saveSpecImg">
	    	<span class="txt-gy">上述操作必须保存后才生效</span>
	    </td>
    </tr>
  </tbody>
</table>
<font color="red">※檔案一次上传不可超过5mb</font>
</s:form>
</div>
<br/>
<c-rt:if test="${mainImgSize > 0}"> 
	商品描述图 / 规格叁数图 <a id="prodImgToggle" href="javascript:;" class="a-more a-blue">(-收缩)</a><br/><br/>
</c-rt:if>
<s:actionerror escape="false"/>
<div id="prodImg">
<s:form action ="uploadProdImg.do" method ="post" id="uploadProdImg" name="uploadProdImg" enctype="multipart/form-data">
<table width="100%" class="tb-data">
	<tbody>
		<tr>
    	<th class="bigth">商品描述图/规格叁数图、商品图片</th>
    </tr>
    <tr>
    	<td>
        <h3 style="float:left" class="tword">商品描述图 / 规格叁数图</h3>
        <div style="width:100%" class="formrow">上传后您可取得图片路径复制到 "商品描述" 或 "规格参数" 区获得展现，以丰富产品内容。</div>
        <div style="width:100%" class="formrow">
        	<input id="MultiFile8_F1" class="multi" type="file" name="imageDesc" size="80%" accept="gif|jpg" />
          <span class="txt-gy">非必填。宽度限<b class="txt-red">700px</b>以内，限jpg、gif</span>
        </div>
        <c-rt:if test="${imgSize le 20}">
	        <h3 style="margin-top:20px;float:left" class="tword">商品图片</h3>
	        <div style="width:100%" class="formrow">
		        <input id="MultiFile8_F2" class="multi" type="file" name="imagePrdt" size="80%" accept="gif|jpg" />
	          <span class="txt-gy">非必填。<b class="txt-red">商品图片宽度必须为520px，高度不超过620px</b>，限jpg、gif</span>
	        </div>
        </c-rt:if>
      </td>
    </tr>
    <tr>
      <td class="set-pdimg-upload">
      	<input type="hidden" name="productId" value="${productId}"/>
      	<input type="button" value="上传商品描述图/商品图片" name="saveProdImg" id="saveProdImg">
      </td>
   	</tr>
  </tbody>
</table>
</s:form>
<br/><br/>
</div>
<s:if test="hasActionMessages()">
	<p>
	<span style="color:red"><s:actionmessage/></span>
	</p>
</s:if>
<br/>
<s:form action="edit.do" method="post" id="editProposeForm" name="editProposeForm">
	<b>请选择图檔类型：</b>
	<s:select id="selImageType" name="selImageType" list="imageTypeMap"></s:select>
	<input type="hidden" name="productId" value="${productId}"/>
</s:form>
<s:form action="batchProcessImage.do" method="post" id="picList" name="batchImgForm" enctype ="multipart/form-data" >
	<input type="hidden" name="selImageType" value="${selImageType}"/>
	<table class="tb-1" width="100%">
		<tr>
			<td colspan="6" style="text-align: right">           
		    <strong>${imageTypeMap[selImageType]}资料共 <s:property value="images.size"/>笔 </strong>
		  </td>
		</tr> 
		<tr>
			<th>图片</th>
			<th>类型</th>
			<th>路径</th>
			<th>排序</th>
			<th>删除</th>
		</tr>		
		<s:if test="images.size > 0">
			<c:forEach items="${images}" var="image" varStatus="rows_index">${image.picDesc}
				<tr class="batch" id="tdDesc_${rows_index.count}" title="建立者:${image.createUser} 建立日期:${image.createDate}<br/>修改者:${image.modifyUser} 修改日期:${image.modifyDate}">
					<td>
						<c:choose>
						<c:when test="${image.type == 'IMGB'}">
							<a href="${imgDomain}${image.imgFilePath}" target="_blank"><img src="${image.imgFilePath}?nocache=<%=dateTime%>"  width="75" height="75" onError="this.src='/PImg/blank_75.gif'"/></a>
						</c:when>
						<c:when test="${image.type == 'RMAIN'}">
							<img src="${imgDomain}${image.imgFilePath}?nocache=<%=dateTime%>"  width="75" height="99"  onError="this.src='/PImg/blank_r93.gif'"/>
						</c:when>
						<c:otherwise>
							<img src="${imgDomain}${image.imgFilePath}?nocache=<%=dateTime%>"  width="75" height="75"  onError="this.src='/PImg/blank_75.gif'"/>
						</c:otherwise>
						</c:choose>
					</td>
					<c:if test="${image.type=='MAIN'}">
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m500.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(500x500<120k)"/>
								<c-rt:set var="width" value="500"/>
								<c-rt:set var="height" value="500"/>
								<c-rt:set var="size" value="120"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m400.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(400x400<90k)"/>
								<c-rt:set var="width" value="400"/>
								<c-rt:set var="height" value="400"/>
								<c-rt:set var="size" value="90"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m250.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(250x250<50k)"/>
								<c-rt:set var="width" value="250"/>
								<c-rt:set var="height" value="250"/>
								<c-rt:set var="size" value="50"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m135.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(135x135<20k)"/>
								<c-rt:set var="width" value="135"/>
								<c-rt:set var="height" value="135"/>
								<c-rt:set var="size" value="20"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m100.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(100x100<10k)"/>
								<c-rt:set var="width" value="100"/>
								<c-rt:set var="height" value="100"/>
								<c-rt:set var="size" value="10"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m75.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(75x75<7k)"/>
								<c-rt:set var="width" value="75"/>
								<c-rt:set var="height" value="75"/>
								<c-rt:set var="size" value="7"/>
							</c-rt:if>							
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_m50.') != -1}">
								<c-rt:set var="imgTypeName" value="封面方形主档图(50x50<5k)"/>
								<c-rt:set var="width" value="50"/>
								<c-rt:set var="height" value="50"/>
								<c-rt:set var="size" value="5"/>
							</c-rt:if>								
						</c:if>
						<c:if test="${image.type=='RMAIN'}">
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_rm530.') != -1}">
								<c-rt:set var="imgTypeName" value="封面长形主档图(400x530<100k)"/>
								<c-rt:set var="width" value="400"/>
								<c-rt:set var="height" value="530"/>
								<c-rt:set var="size" value="100"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_rm330.') != -1}">
								<c-rt:set var="imgTypeName" value="封面长形主档图(250x330<50k)"/>
								<c-rt:set var="width" value="250"/>
								<c-rt:set var="height" value="330"/>
								<c-rt:set var="size" value="50"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_rm225.') != -1}">
								<c-rt:set var="imgTypeName" value="封面长形主档图(170x225<30k)"/>
								<c-rt:set var="width" value="170"/>
								<c-rt:set var="height" value="225"/>
								<c-rt:set var="size" value="30"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_rm180.') != -1}">
								<c-rt:set var="imgTypeName" value="封面长形主档图(135x180<20k)"/>
								<c-rt:set var="width" value="135"/>
								<c-rt:set var="height" value="180"/>
								<c-rt:set var="size" value="20"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_rm130.') != -1}">
								<c-rt:set var="imgTypeName" value="封面长形主档图(100x130<12k)"/>
								<c-rt:set var="width" value="100"/>
								<c-rt:set var="height" value="130"/>
								<c-rt:set var="size" value="12"/>
							</c-rt:if>
							<c-rt:if test="${fn:indexOf(image.imgFilePath,'_rm93.') != -1}">
								<c-rt:set var="imgTypeName" value="封面长形主档图(70x93<7k)"/>
								<c-rt:set var="width" value="70"/>
								<c-rt:set var="height" value="93"/>
								<c-rt:set var="size" value="7"/>
							</c-rt:if>
						</c:if>
						<c:if test="${image.type=='DESC'}"><c-rt:set var="imgTypeName" value="描述图"/></c:if>
						<c:if test="${image.type=='IMGB'}">
							<c-rt:set var="imgTypeName" value="其他图"/>
							<c-rt:set var="width" value="520"/>
							<c-rt:set var="height" value="620"/>
						</c:if>					 
					<td id="td${rows_index.count}">${imgTypeName}</td>
					<td>
						<c:choose>
						<c:when test="${image.type == 'IMGB'}">
							商品大图：${imgDomain}${image.imgFilePath}<br/>
							商品小图：${imgDomain}${fn:substring(image.imgFilePath,0,fn:length(image.imgFilePath)-5)}s.jpg
							<input type="hidden" id="IMGB_FILE_NAME_${rows_index.count}" value="${imgDomain}${image.imgFilePath}"/>
						</c:when>
						<c:otherwise>
						${imgDomain}${image.imgFilePath}
						</c:otherwise>
						</c:choose>
						<br/>
						<input id="image_batch_${rows_index.count}" type="file" name="batch" maxlength="1" size="25"/>
						<input type="button" name="clearBtn" value="清除图檔" id="clear_batch_${rows_index.count}"/>
						<span id="batchSpan${rows_index.count}"></span>
					</td>
					<td>
						<c:if test="${image.type!='MAIN' and image.type !='RMAIN'}">
						<a href="javascript:void(0);" onClick="return moveRowUp($(this),'batch');" href="#">↑上移</a><br/>
						<a href="javascript:void(0);" onClick="return moveRowDown($(this),'batch');" href="#">↓下移</a>
						</c:if>						
					</td>
					<td>
						<c:if test="${image.type!='MAIN' and image.type !='RMAIN'}"><input name="deletePic" type="checkbox" value="${image.id}" id="dp_${rows_index.count}"/></c:if>
						<input type="hidden" name="imgIds" id="imgId_${rows_index.count}" value="${image.id}"/>
						<input type="hidden" id="correct_batch_${rows_index.count}" value=""/>
						<input type="hidden" id="width_batch_${rows_index.count}" value="${width}"/>
						<input type="hidden" id="height_batch_${rows_index.count}" value="${height}"/>
						<input type="hidden" id="size_batch_${rows_index.count}" value="${size}"/>
					</td>
				</tr>
			</c:forEach> 
			<tr>
				<td colspan="6">
					<input type="button" id="batchbtn" value="批次作业"/>
				</td>
			</tr>
  	</s:if>
  	<s:else>
	  	<tr>
				<td colspan="6">
					查无资料
				</td>
			</tr>
  	</s:else>
	</table>
</s:form>
<s:form action="saveImgStep.do" name="saveImgStep" id="saveImgStep" method="post">
	<input type="button" name="previous" id="previous" value="上一步"/>
	<input type="button" name="next" id="next" value="下一步"/>
</s:form>